package com.example.gradledemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.jltx.compiler.MyServiceCenter

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        //app层先注入接口和最后实现类
        MyServiceCenter.registerMyService(IUserService::class.java, UserServiceImpl::class.java)
        MyServiceCenter.registerMyService(IImService::class.java, ImServiceImpl::class.java)
        //再调用
        val iUserService = MyServiceCenter.getMyService<IUserService>(IUserService::class.java)
        val iImService = MyServiceCenter.getMyService<IImService>(IImService::class.java)
        Log.d("aidenquan", iUserService.userName)
        Log.d("aidenquan", iImService.imName)
    }
}